package com.pany.rememberpass.Adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.PagerAdapter;

import com.pany.rememberpass.R;

import java.util.List;

/**
 * @name： RememberPass
 * @author： zs
 * @time： 2022/5/20 0020
 */

public class MyViewPagerAdapter2 extends  RecyclerView.Adapter<MyViewPagerAdapter2.ViewHolder> {
    int[] colors = {
            R.drawable.test1,
            R.drawable.test2,
            R.drawable.test3,
            R.drawable.test4,
            R.drawable.test5,
    };
    private Context context;

    public MyViewPagerAdapter2(Context context) {
        this.context = context;
    }


    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.page2_layout, parent, false);
        return new ViewHolder(view);
    }


    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.layout.setImageResource(colors[position]);
    }

    @Override
    public int getItemCount() {
        return colors.length;
    }

    class ViewHolder extends RecyclerView.ViewHolder {
        ImageView layout;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            layout = itemView.findViewById(R.id.page2_layout);
//                    ImageView imageView = new ImageView(context);
//            imageView.setImageResource(ims[position]);
//            container.addView(imageView);
        }
    }

}


//
//
//
//
//
//
//    @Override
//    public int getCount() {
//        return ims.length;
//    }
//
//    @Override
//    public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
//
//        return view == object;
//    }
//
//    @NonNull
//    @Override
//    public Object instantiateItem(@NonNull ViewGroup container, int position) {
//        ImageView imageView = new ImageView(context);
//        imageView.setImageResource(ims[position]);
//        container.addView(imageView);
//        //最后要返回的是控件本身
//        return imageView;
//    }
//
//    @Override
//    public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
//        container.removeView((View) object);
//    }

